﻿using Inovout.Cloud.Messager.Domain;
using Inovout.Component;
using Inovout.Data.Service;
using Inovout.Organization.Domain;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Inovout.Cloud.Messager.Service
{
    public class MessageTemplateService
    {
        public static void InsertMessageTemplate(MessageTemplates Msg)
        {
            IRepositoryService<MessageTemplates> Service = ComponentRegistry.Resolve<IRepositoryService<MessageTemplates>>();
             Service.Save(new MessageTemplates(Msg.UserId, Msg.TemplateId, Msg.Content, Msg.Parameters));
        }

        public static MessageTemplates GetMessageTemplate(string UserId, string TemplateId)
        {
            IRepositoryService<MessageTemplates> Service = ComponentRegistry.Resolve<IRepositoryService<MessageTemplates>>();
            Service.Save(new MessageTemplates());
            return Service.Query().Where(c => c.UserId == UserId && c.TemplateId == TemplateId).SingleOrDefault();
        }
    }
}
